<%@ page language="java" contentType="text/html; charset=UTF-8"  
    pageEncoding="UTF-8"%>  
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  
<html>  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
<title>Cometd首页</title>
<script type="text/javascript" src="./JS/cometd/comet4j.js"></script>
<script type="text/javascript">

    var projectPath = '<%= request.getContextPath()%>';
    function cometdCallback(text){
      //  var kbDom = document.getElementById('num1');
         var number1 = document.getElementById('number1');  
        var number2 = document.getElementById('number2');  
       // kbDom.innerHTML = text;
       number1.innerHTML = text;
       number2.innerHTML = text;
       
    }
    function init() {

        JS.Engine.on(
        {
            //number : cometdCallback
            number1 : cometdCallback,
            number2 : cometdCallback
            } );
         // 建立连接，conn 即web.xml中 CometServlet的<url-pattern>
        JS.Engine.start(projectPath+'/conn');

    }
</script>
</head>
<body onload="init()">
    数字1：
    <span id="number1">...</span>
    <br>
    数字2：
    <span id="number2">...</span>
</body>
</html>